package run;

//import mapred.AntBuilder;
import addEdges.AddEdges;
import addEdges.AddEdgesMerge;
import InitialRank.HashHostRank;
import InitialRank.InitialGetReady;
import InitialRank.InitialRank;
import hashLinkGraph.HashLinkGraph;
import mapred.AntBuilder;
import pageRank.Calc;
import pageRank.GetReady;
import pageRank.Readable;
import recoverLinkGraph.RecoverLinkGraph;
import removeDanglingPage.RemoveDP;
import removeDanglingPage.RemoveDP_GetReady;
import sameHostLinkGraph.SameHost;

public class AllPageRank_job {

	public static void main(String[] args) throws Exception {
		String linkGraph = "/user/renp/Full/LinkGraph";
		String result = "/user/jwLiu/PageRank";
		String hostRank = "/user/renp/CJK/HostRank/Final";
		String finalResult = result + "/FinalResult";
		String hashLinkGraph = result + "/HashLinkGraph";
		String danglingPage = result + "/DanglingPage";
		String recoverLinkGraph = result + "/LinkGraphCore";
		String sameHostLG = result + "/SameHostLinkGraph";
		String sameHostPR = result + "/SameHostPageRank";
		String hashHostRank = result + "/HashHostRank";
		String initialRank = result + "/InitialRank";
		String finalPR = result + "/FinalPageRank";
		
		
		new HashLinkGraph(linkGraph, hashLinkGraph).submit();
		
		new RemoveDP_GetReady(hashLinkGraph, danglingPage).submit();
		
		
		for(int i = 1; i < 6; i++) {
			new RemoveDP(danglingPage, danglingPage, i).submit();
		}
		new RecoverLinkGraph(danglingPage+"/RemoveDP_5", recoverLinkGraph).submit();
		new SameHost(recoverLinkGraph, sameHostLG).submit();
		new GetReady(sameHostLG, sameHostPR).submit();
		for(int i = 1; i < 20; i++) {
			new Calc(sameHostPR, sameHostPR, i).submit();
		}
		new Readable(sameHostPR, sameHostPR+"/result", 19, new String[0]).submit();
		new HashHostRank(hostRank, hashHostRank).submit();
		new InitialRank(hashHostRank, sameHostPR+"/result", initialRank).submit();
		new InitialGetReady(initialRank, recoverLinkGraph, finalPR).submit();
		for(int j = 1; j < 20; j++) {
			new Calc(finalPR, finalPR, j).submit();
		}
		new Readable(finalPR, finalResult+"/MergeAddEdges_0", 19, new String[0]).submit();
		for(int k = 0; k < 6; k++) {
			new AddEdges(danglingPage, finalResult, finalResult, k).submit();
			new AddEdgesMerge(finalResult, finalResult, k).submit();
		}
		
	}
}
